#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    //设置画笔
    QPen pen(QColor(255,0,0));
    //设置画笔宽度
    pen.setWidth(3);
    //设置画笔风格
    pen.setStyle(Qt::DashLine);
    //使用画笔
    //开始绘制
    painter.setPen(pen);
    //设置画刷
    //设置画刷风格
    QBrush brush(Qt::cyan);
    brush.setStyle(Qt::Dense1Pattern);
    painter.setBrush(brush);
    //绘制图片
    //将图片中心进行旋转
    painter.translate(200,300);
    painter.rotate(90);
    //还原坐标原点
    painter.translate(-200,-300);
    //绘制图片
    painter.drawPixmap(0,0,QPixmap(":/image.jpg"));
    //painter.drawEllipse(QPoint(200,200),100,100);
}

